import {
  Body,
  Controller,
  Get,
  Inject,
  Param,
  Post,
  Query,
} from '@nestjs/common';
import { StatisticService } from './statistic.service';

@Controller('statistic')
export class StatisticController {
  @Inject(StatisticService)
  private statisticService: StatisticService;

  @Get('dau')
  async getDAU(
    @Query('startDate') startDate: string,
    @Query('endDate') endDate: string,
  ) {
    return this.statisticService.getDAU(startDate, endDate);
  }

  @Get('mau')
  async getMAU(
    @Query('startMonth') startMonth: string,
    @Query('endMonth') endMonth: string,
  ) {
    return this.statisticService.getMAU(startMonth, endMonth);
  }

  @Get('retention')
  async getRetentionRate(
    @Query('date') date: string,
    @Query('daysAfter') daysAfter: string, // 改为接受逗号分隔的多个天数
  ) {
    return await this.statisticService.getRetentionRate(date, daysAfter);
  }

  @Get('top-keywords')
  async getTopKeywords() {
    return this.statisticService.getTopKeywords();
  }
  @Get('top-enterprises')
  async getTopSearchedEnterprises() {
    return this.statisticService.getTopSearchedEnterprises();
  }

  @Get('daily-comments')
  async getDailyCommentStats(
    @Query('startDate') startDate: string,
    @Query('endDate') endDate: string,
  ) {
    return this.statisticService.getDailyCommentStats(startDate, endDate);
  }

  @Get('daily-keys')
  async getDailyKeyStats(
    @Query('startDate') startDate: string,
    @Query('endDate') endDate: string,
  ) {
    return this.statisticService.getDailyKeyStats(startDate, endDate);
  }
}
